<template>
  <div class="app">
    <h3>App组件，{{ car.name }}: {{ car.price }}</h3>
    <Suspense>
      <template v-slot:default>
        <Child></Child>
      </template>
      <template v-slot:fallback>
        <h3>加载中...</h3>
      </template>
    </Suspense>
  </div>
</template>

<script>

// import Child from "@/components/Child";
import {defineAsyncComponent, provide, reactive} from "vue";

const Child = defineAsyncComponent(() => {
  return import('@/components/Child');
}); // 异步引入，子组件后出来
export default {
  name: "App",
  components: {Child},
  setup(props, context) {
    let car = reactive({
      name: '奔驰',
      price: '40W'
    });
    provide('car', car); // 给后代组件传递数据
    return {
      car
    }
  }
}
</script>

<style scoped>
.app {
  background-color: gray;
  padding: 10px;
}
</style>